<?php

if(!defined('IN_ECS'))
{
	die('Hacking attempt');
}

class cls_image
{
	var $error_no = 0;
	var $error_msg ='';
	var $images_dir = IMAGE_DIR;
	var $data_dir = DATA_DIR;
	var $bgcolor = '';
	var $type_maping = array(1=>'image/gif',2=>'image/jpeg',3=>'image/png');
	
	function __construct($bgcolor='')
	{
		$this->cls_image($bgcolor);
	}
	
	function cls_image($bgcolor='')
	{
		if($bgcolor)
		{
			$this->bgcolor = $bgcolor;
		}
		else
		{
			$this->bgcolor = "#FFFFFF";
		}
	}
	
	function gd_version()
	{
		static $version = -1;
		
		if($version >= 0)
		{
			return $version;
		}
		
		if(!extension_loaded('gd'))
		{
			$version = 0;
		}
		else
		{
			if(PHP_VERSION >= '4.3')
			{
				if(function_exists('gd__info'))
				{
					$ver_info = gd_info();
					preg_match('/\d/', $ver_info['GD Version'],$match);
					$version = $match[0];
				}
				else 
				{
					if(function_exists('imagecreatetruecolor'))
					{
						$version = 2;
					}
					elseif(function_exists('iamgecreate'))
					{
						$version = 1;
					}
				}
			}
			else
			{
				if(preg_match('/phpinfo/', ini_get('disable_functions')))
				{
					$version = 1;
				}
				else 
				{
					ob_start();
					phpinfo(8);
					$info = ob_get_contents();
					ob_end_clean();
					$info = stristr($info, 'gd_version');
					preg_match('/\d/',$info,$match);
					$version = $match[0];
				}
			}
		}
		return $version;
	}
	
	
	
}
	